package jjn.round1;

import java.util.HashMap;
import java.util.Map;

/**
 * 剑指 Offer 53 - I. 在排序数组中查找数字 I
 *
 * @author Jiang Jining
 * @since 2022-07-19 23:39
 */
public class Offer_53 {
    
    public int search(int[] nums, int target) {
        Map<Integer, Integer> map = new HashMap<>(Math.max(nums.length, 8));
        for (int num : nums) {
            int count = map.getOrDefault(num, 0);
            count++;
            map.put(num, count);
        }
        return map.getOrDefault(target, 0);
    }
}
